package com.qf.ts.platform.front.web;

import com.qf.ts.platform.commons.pojo.R;
import com.qf.ts.platform.front.domain.Form;
import com.qf.ts.platform.front.service.FormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/form")
public class FormController {

    @Autowired
    private FormService formService;

    @PostMapping("/")
    public R addForm(@RequestBody Form form, HttpSession session){

        String uid = (String)session.getAttribute("uid");

//        uid = "25";

        Integer result = formService.addForm(uid,form);

        if(result > 0){

            return R.ok();

        }

        return R.error("fail");
    }


}
